//
//  ZanPersonNumberVC.swift
//  甜言蜜语
//
//  Created by yingli_yanfa_liuxingyu on 16/9/13.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit

class ZanPersonNumberVC: UIViewController,UITableViewDelegate, UITableViewDataSource {
    
     @IBOutlet weak var tableView: UITableView!
    
    var modelList: allReplyInfo?{
        didSet{
           
        }
    }

   
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.delegate = self
        self.tableView.dataSource = self
        
        self.title = "赞过的人"
        
    publicMethod.hiddleExtendCellForTableView(self.tableView)
        
        let cellNib = UINib(nibName: "ZanPersonNumberCell", bundle: nil)
        self.tableView.registerNib(cellNib, forCellReuseIdentifier: "ZanPersonNumberCell")
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //MARK:tableviewDataSource
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if self.modelList?.userdzList.count == 0{
            return 0
        }else{
            return (self.modelList?.userdzList.count)!
        }
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 50
    }
    
    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        if(cell.respondsToSelector(Selector("setSeparatorInset:"))) {
            cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0)
        }
        if(cell.respondsToSelector(Selector("setLayoutMargins:"))) {
            cell.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0)
        }
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCellWithIdentifier("ZanPersonNumberCell") as! ZanPersonNumberCell
        let model = self.modelList!.userdzList[indexPath.row]
        cell.idLbl.text = model.name
        cell.timg.sd_setImageWithURL(NSURL(string: model.timg), placeholderImage: UIImage(named: "placeholder"))
        return cell
        

    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
        let vc = storyboard?.instantiateViewControllerWithIdentifier("UserHomeTableViewController") as! UserHomeTableViewController
        
        vc.userId = Int((modelList?.userdzList[indexPath.row].id)!)
        
        self.navigationController?.pushViewController(vc, animated: true)
        
        
    }

    

   

}
